package main.java.dal.valueobject;

public class UserVO extends ValueObject {
    
    private String login;
    private String password;
    private long groupID;
    private GroupVO group;
    
    public UserVO(long id, String name, String login, String password,
	    long groupID) {
	super(id,name);
	this.login = login;
	this.password = password;
	this.groupID = groupID;
    }
    
    /**
     * @return the login
     */
    public String getLogin() {
	return login;
    }
    
    /**
     * @param login
     *            the login to set
     */
    public void setLogin(String login) {
	this.login = login;
    }
    
    /**
     * @return the password
     */
    public String getPassword() {
	return password;
    }
    
    /**
     * @param password
     *            the password to set
     */
    public void setPassword(String password) {
	this.password = password;
    }
    
    /**
     * @return the groupID
     */
    public long getGroupID() {
	return groupID;
    }
    
    /**
     * @param groupID
     *            the groupID to set
     */
    public void setGroupID(int groupID) {
	this.groupID = groupID;
    }
    
    /**
     * @return the group
     */
    public GroupVO getGroup() {
	return group;
    }
    
    /**
     * @param group
     *            the group to set
     */
    public void setGroup(GroupVO group) {
	this.group = group;
    }
    
    /*
     * (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
	return String.format(
		"UserVO [id=%s, name=%s, login=%s, password=%s, groupID=%s, group=%s]",
		id, name, login, password, groupID, group);
    }
    
    /*
     * (non-Javadoc)
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode() {
	final int prime = 31;
	int result = super.hashCode();
	result = prime * result + ((group == null) ? 0 : group.hashCode());
	result = prime * result + (int) (groupID ^ (groupID >>> 32));
	result = prime * result + ((login == null) ? 0 : login.hashCode());
	result = prime * result
		+ ((password == null) ? 0 : password.hashCode());
	return result;
    }
    
    /*
     * (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
	if (this == obj) {
	    return true;
	}
	if (!super.equals(obj)) {
	    return false;
	}
	if (!(obj instanceof UserVO)) {
	    return false;
	}
	UserVO other = (UserVO) obj;
	if (group == null) {
	    if (other.group != null) {
		return false;
	    }
	} else if (!group.equals(other.group)) {
	    return false;
	}
	if (groupID != other.groupID) {
	    return false;
	}
	if (login == null) {
	    if (other.login != null) {
		return false;
	    }
	} else if (!login.equals(other.login)) {
	    return false;
	}
	if (password == null) {
	    if (other.password != null) {
		return false;
	    }
	} else if (!password.equals(other.password)) {
	    return false;
	}
	return true;
    }
    
}
